package cn.iocoder.yudao.module.aiposter.controller.app.vec;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.aiposter.controller.app.poster.vo.req.AppPosterPageReqVO;
import cn.iocoder.yudao.module.aiposter.controller.app.poster.vo.req.AppPosterSaveReqVO;
import cn.iocoder.yudao.module.aiposter.controller.app.poster.vo.req.PosterGenerateReqVO;
import cn.iocoder.yudao.module.aiposter.controller.app.poster.vo.resp.AppPosterRespVO;
import cn.iocoder.yudao.module.aiposter.controller.app.vec.vo.VecTemplateMixSimilaritySearchReqVO;
import cn.iocoder.yudao.module.aiposter.controller.app.vec.vo.VecTemplateSimilaritySearchReqVO;
import cn.iocoder.yudao.module.aiposter.controller.app.vec.vo.VecTemplateSimilaritySearchRespVO;
import cn.iocoder.yudao.module.aiposter.dal.dataobject.poster.PosterDO;
import cn.iocoder.yudao.module.aiposter.remote.VecClient;
import cn.iocoder.yudao.module.aiposter.service.vec.VecService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "海报APP - Vec")
@RestController
@RequestMapping("/ai-poster/vec")
@Validated
public class VecController {

    @Resource
    private VecService vecService;


    @PostMapping("/template_similarity_search")
    @Operation(summary = "模版相似度查询")
    @PermitAll
    public CommonResult<List<VecTemplateSimilaritySearchRespVO>> similaritySearch(@Valid @RequestBody VecTemplateSimilaritySearchReqVO reqVO) {
        return success(vecService.similaritySearch(reqVO));
    }

    @PostMapping("/template_mix_similarity_search")
    @Operation(summary = "混合模版相似度查询")
    @PermitAll
    public CommonResult<List<VecTemplateSimilaritySearchRespVO>> similaritySearchMix(@Valid @RequestBody VecTemplateMixSimilaritySearchReqVO reqVO) {
        return success(vecService.similaritySearchMix(reqVO));
    }

    @GetMapping("/reset_index")
    @Operation(summary = "重建向量库索引")
    @PermitAll
    public CommonResult<Boolean> resetIndex() {
        return success(vecService.resetIndex());
    }
}
